package com.qbw.app.request.impl;

import android.text.TextUtils;

import com.http.okhttp.HttpTask;
import com.lib.util.StringUtil;
import com.qbw.actionmanager.ActionManager;
import com.qbw.app.Config;
import com.qbw.app.Constant;
import com.qbw.app.action.DeleteVehicleAction;
import com.qbw.app.action.EditVehicleAction;
import com.qbw.app.manager.MapManager;
import com.qbw.app.model.BaseModel;
import com.qbw.app.model.Coolant;
import com.qbw.app.model.ElectricArea;
import com.qbw.app.model.ElectricAreaDetail;
import com.qbw.app.model.EstimateDistance;
import com.qbw.app.model.HomeStatus;
import com.qbw.app.model.FindData;
import com.qbw.app.model.Location;
import com.qbw.app.model.Problem;
import com.qbw.app.model.TireData;
import com.qbw.app.model.Travel;
import com.qbw.app.model.TravelChart;
import com.qbw.app.model.TravelData;
import com.qbw.app.model.TravelGps;
import com.qbw.app.model.Vehicle;
import com.qbw.app.model.VehicleHomeInfo;
import com.qbw.app.model.Voltage;
import com.qbw.app.model.Warning;
import com.qbw.app.module.common.util.Gps;
import com.qbw.app.module.common.util.PositionUtil;
import com.qbw.app.request.IVehicleRequest;
import com.qbw.spm.P;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author QBW
 * @date 2019/8/29
 */
public class VehicleRequest implements IVehicleRequest {

    /**
     * 车辆列表
     */
    public static final String METHOD_VEHICLE_LIST = "getVehicleList";
    /**
     * 预估里程
     */
    public static final String METHOD_ESTIMETE_DISTANCE = "vehicleHomePage/getLastmileage";
    /**
     * 车辆-电压
     */
    public static final String METHOD_VOLTAGE = "vehicleHomePage/getVoltage";
    /**
     * 车辆-冷却液
     */
    public static final String METHOD_COOLANT = "vehicleHomePage/getCoolant";
    /**
     * 车况首页(冷却液,电压)状态,故障数量
     */
    public static final String METHOD_HOME_STATUS = "vehicleHomePage/getPageStatus";
    /**
     * 车辆故障(历史故障,实时故障)
     */
    public static final String METHOD_PROGLEM_LIST = "fault/getfaultData";
    /**
     * 获取车辆实时位置
     */
    public static final String METHOD_LOCATION = "getVehicleLocation";
    /**
     * 获取车辆最后一条行程
     */
    public static final String METHOD_LAST_TRAVEL = "travel/lastTravel";
    /**
     * 车辆告警
     */
    public static final String METHOD_ALARM_LIST = "alarm/getalarm";
    /**
     * 车辆告警事件类型
     */
    public static final String METHOD_EVENT_TYPE_LIST = "alarm/getQueryAlarmConfig";
    /**
     * 车况首页
     */
    public static final String METHOD_HOME_INFO = "vehicleHomePage/getCondIndex";
    /**
     * 根据行程获取gps信息
     */
    public static final String METHOD_TRAVEL_GPS = "travel/gps";
    /**
     * 获取车辆行程列表
     */
    public static final String METHOD_TRAVEL_LIST = "travel/listTravel";
    /**
     * 获取车辆行程列表
     */
    public static final String METHOD_TRAVEL_TRAVELCHART = "travel/travelChart";
    /**
     * 行程详情
     */
    public static final String METHOD_TRAVEL_DETAIL = "travel/detail";
    /**
     * 一键寻车
     */
    public static final String METHOD_SEARCH_VEHICLE = "api/lightOn";
    /**
     * 电子围栏列表
     */
    public static final String METHOD_ELECTRIC_AREA_LIST = "fence/list";
    /**
     * 删除电子围栏
     */
    public static final String METHOD_ELECTRIC_AREA_DELETE = "fence/delete";
    /**
     * 添加电子围栏
     */
    public static final String METHOD_ELECTRIC_AREA_ADD = "fence/add";
    /**
     * 更新围栏信息
     */
    public static final String METHOD_ELECTRIC_AREA_UPDATE = "fence/update";
    /**
     * 车辆详情
     */
    public static final String METHOD_VEHICLE_DETAIL = "vehicle/detail";
    /**
     * 添加车辆
     */
    public static final String METHOD_VEHICLE_ADD = "vehicle/add";

    /**
     * 车辆绑定设备
     */
    public static final String METHOD_OPERATION_BINDDEVICE = "operation/" + Config.VER + "/bindDevice";

    /**
     * 获取当前告警推送设置列表
     */
    public static final String METHOD_WARNING_CONFIG = "alarm/getConfig";
    /**
     * 设置告警推送
     */
    public static final String METHOD_WARNING_CONFIG_UPDATE = "alarm/updateConfig";
    /**
     * 根据vin获取车辆信息
     */
    public static final String METHOD_VEHICLE_DETAIL_BY_VIN = "vehicle/getInfoByVin";
    /**
     * 围栏详情
     */
    public static final String METHOD_ELECTRIC_AREA_DETAIL = "fence/detail";
    /**
     * 删除用户拥有的车辆
     */
    public static final String METHOD_DELETE_VEHICLE = "vehicle/delete";
    /**
     * 编辑车辆
     */
    public static final String METHOD_EDIT_VEHICLE = "vehicle/edit";
    /**
     * 获取行程段中的告警点
     */
    public static final String METHOD_TRAVEL_ALRAMS = "travel/alarms";
    /**
     * 更新已读时间
     */
    public static final String METHOD_MARK_ALL_WARNING_READ = "alarm/updateReadTime";

    // 诺马
    /**
     * 添加车辆
     */
    public static final String METHOD_VEHICLE_ADD_V = "vehicle/" + Config.VER + "/add";
    /**
     * 车况首页
     */
    public static final String METHOD_HOME_INFO_V = "vehicleHomePage/" + Config.VER + "/getCondIndex";
    /**
     * 查看寻车数据状态
     */
    public static final String METHOD_LIGHT_DATA_V = "parts/getLightData";
    /**
     * 下发设置寻车开关
     */
    public static final String METHOD_LIGHT_SENDSWITCH_V = "parts/sendLightSwitch";
    /**
     * 设置寻车时长
     */
    public static final String METHOD_LIGHT_SENDDURATION_V = "parts/sendLightDuration";
    /**
     * 查看轮胎胎压状态
     */
    public static final String METHOD_TIRE_STATE_V = "parts/getTirePressureState";
    /**
     * 查看轮胎胎压状态数据
     */
    public static final String METHOD_TIRE_DATA_V = "parts/tirePressure";

    @Override
    public HttpTask getVehicleList(HttpTask.CallBack callBack) {
        return HttpTask.create(METHOD_VEHICLE_LIST,
                               null,
                               Vehicle.Response.class,
                               null,
                               null,
                               callBack,
                               null).get();
    }

    @Override
    public HttpTask getEstimeteDistance(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_ESTIMETE_DISTANCE,
                               params,
                               EstimateDistance.Response.class,
                               null,
                               null,
                               callBack,
                               null).get();
    }

    @Override
    public HttpTask getVoltage(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_VOLTAGE,
                               params,
                               Voltage.Response.class,
                               null,
                               null,
                               callBack,
                               null).get();
    }

    @Override
    public HttpTask getCoolant(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_COOLANT, params, Coolant.Response.class, callBack).get();
    }

    @Override
    public HttpTask getHomeStatus(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_HOME_STATUS, params, HomeStatus.Response.class, callBack)
                       .get();
    }

    @Override
    public HttpTask getProblemList(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_PROGLEM_LIST, params, Problem.Response.class, callBack).get();
    }

    @Override
    public HttpTask getVehicleLocation(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_LOCATION, params, Location.Response.class, callBack)
                       .setBackgroundBeforeCallBack(new HttpTask.SimpleFlowCallBack() {
                           @Override
                           public void onSuccess(HttpTask httpTask,
                                                 Object entity,
                                                 String modelStr) {
                               Location.Response response = (Location.Response) entity;
                               Location location = response.getData();
                               location.setLatitude84(location.getLatitude());
                               location.setLongitude84(location.getLongitude());
                               Gps gpsAfterConverted;
                               if (MapManager.getInstance().isUseBaidu()) {
                                   gpsAfterConverted = PositionUtil.gps84_to_bd09_byBaiduSdk(
                                           location.getLatitude(),
                                           location.getLongitude());
                                   location.setLatitude(gpsAfterConverted.getWgLat());
                                   location.setLongitude(gpsAfterConverted.getWgLon());
                                   if (location.getGpsDataSize() > 0) {
                                       for (TravelGps gps : response.getData().getGpsDatas()) {
                                           gpsAfterConverted = PositionUtil.gps84_to_bd09_byBaiduSdk(
                                                   gps.getLatitude(),
                                                   gps.getLongitude());
                                           gps.setLatitude(gpsAfterConverted.getWgLat());
                                           gps.setLongitude(gpsAfterConverted.getWgLon());
                                       }
                                   }
                               } else {
                                   gpsAfterConverted = PositionUtil.gps84_To_Gcj02(location.getLatitude(),
                                                                                   location.getLongitude());
                                   location.setLatitude(gpsAfterConverted.getWgLat());
                                   location.setLongitude(gpsAfterConverted.getWgLon());
                                   if (location.getGpsDataSize() > 0) {
                                       for (TravelGps gps : response.getData().getGpsDatas()) {
                                           gpsAfterConverted = PositionUtil.gps84_To_Gcj02(gps.getLatitude(),
                                                                                           gps.getLongitude());
                                           gps.setLatitude(gpsAfterConverted.getWgLat());
                                           gps.setLongitude(gpsAfterConverted.getWgLon());
                                       }
                                   }
                               }
                           }
                       })
                       .get();
    }

    @Override
    public HttpTask getVehicleLastStroke(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_LAST_TRAVEL, params, Travel.Response.class, callBack).get();
    }

    @Override
    public HttpTask getAlarmList(List<String> vehicleCodes,
                                 List<String> alarmIdList,
                                 int pageCount,
                                 int pageSize,
                                 HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCodes == null ? new ArrayList<String>() : vehicleCodes);
        params.put("alarmIdList", alarmIdList == null ? new ArrayList<String>() : alarmIdList);
        params.put("pageCount", pageCount);
        params.put("pageSize", pageSize);
        return HttpTask.create(METHOD_ALARM_LIST, params, Warning.Response.class, callBack).post();
    }

    @Override
    public HttpTask getHomeInfo(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_HOME_INFO, params, VehicleHomeInfo.Response.class, callBack)
                       .get();
    }

    @Override
    public HttpTask getTravelGps(String travelCode, String adsorbent, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("travelCode", travelCode);
        params.put("adsorbent", adsorbent);
        return HttpTask.create(METHOD_TRAVEL_GPS,
                               params,
                               TravelGps.Response.class,
                               null,
                               new HttpTask.SimpleFlowCallBack() {
                                   @Override
                                   public void onSuccess(HttpTask httpTask,
                                                         Object entity,
                                                         String modelStr) {
                                       super.onSuccess(httpTask, entity, modelStr);
                                       TravelGps.Response response = (TravelGps.Response) entity;
                                       if (!response.getData().isEmpty()) {
                                           Gps gpsAfterConverted;
                                           if (MapManager.getInstance().isUseBaidu()) {
                                               for (TravelGps gps : response.getData()) {
                                                   gpsAfterConverted = PositionUtil.gps84_to_bd09_byBaiduSdk(
                                                           gps.getLatitude(),
                                                           gps.getLongitude());
                                                   gps.setLatitude(gpsAfterConverted.getWgLat());
                                                   gps.setLongitude(gpsAfterConverted.getWgLon());
                                               }
                                           } else {
                                               for (TravelGps gps : response.getData()) {
                                                   gpsAfterConverted = PositionUtil.gps84_To_Gcj02(
                                                           gps.getLatitude(),
                                                           gps.getLongitude());
                                                   gps.setLatitude(gpsAfterConverted.getWgLat());
                                                   gps.setLongitude(gpsAfterConverted.getWgLon());
                                               }
                                           }
                                       }
                                   }
                               },
                               callBack,
                               null).get();
    }

    @Override
    public HttpTask getTravelList(String vehicleCode,
                                  long sTime,
                                  long eTime,
                                  int page,
                                  int limit,
                                  HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        params.put("sTime", sTime);
        params.put("eTime", eTime);
        params.put("page", page);
        params.put("limit", limit);
        return HttpTask.create(METHOD_TRAVEL_LIST, params, TravelData.Response.class, callBack)
                       .get();
    }

    @Override
    public HttpTask getTravellChart(String vehicleCode, long sTime, long eTime, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        params.put("sTime", sTime);
        params.put("eTime", eTime);
        return HttpTask.create(METHOD_TRAVEL_TRAVELCHART, params, TravelChart.ResponseList.class, callBack)
                .get();
    }

    @Override
    public HttpTask getTravelDetail(String travelCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("travelCode", travelCode);
        return HttpTask.create(METHOD_TRAVEL_DETAIL, params, Travel.Response.class, callBack).get();
    }

    @Override
    public HttpTask searchVehicle(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_SEARCH_VEHICLE, params, BaseModel.class, callBack).get();
    }

    @Override
    public HttpTask getVehicleDetail(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_VEHICLE_DETAIL, params, Vehicle.ResponseOne.class, callBack)
                       .get();
    }

    @Override
    public HttpTask addVehicle(String vin,
                               String vehicleNick,
                               String engineNo,
                               HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vin", vin);
        params.put("vehicleNick", vehicleNick);
        params.put("engineNo", engineNo);
        return HttpTask.create(METHOD_VEHICLE_ADD, params, BaseModel.class, callBack).post();
    }

    @Override
    public HttpTask getElectricAreaList(int page, int limit, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", limit);
        return HttpTask.create(METHOD_ELECTRIC_AREA_LIST,
                               params,
                               ElectricArea.ResponseList.class,
                               callBack).get();
    }

    @Override
    public HttpTask addElectricArea(double latitude,
                                    double longitude,
                                    double radius,
                                    String fenceName,
                                    int fenceState,
                                    String triggerSet,
                                    List<String> vehicleCodes,
                                    HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        HashMap<String, Object> fenceDetail = new HashMap<>();
        params.put("fenceDetail", fenceDetail);
        params.put("vehicleCodes", vehicleCodes);
        fenceDetail.put("latitude", latitude);
        fenceDetail.put("longitude", longitude);
        fenceDetail.put("radius", radius);
        params.put("fenceName", fenceName);
        params.put("fenceState", fenceState);
        params.put("triggerSet", triggerSet);
        return HttpTask.create(METHOD_ELECTRIC_AREA_ADD, params, BaseModel.class, callBack).post();
    }

    @Override
    public HttpTask updateElectricArea(long fenceId,
                                       double latitude,
                                       double longitude,
                                       double radius,
                                       String fenceName,
                                       int fenceState,
                                       String triggerSet,
                                       List<String> vehicleCodes,
                                       HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        HashMap<String, Object> fenceDetail = new HashMap<>();
        params.put("fenceDetail", fenceDetail);
        params.put("vehicleCodes", vehicleCodes);
        fenceDetail.put("latitude", latitude);
        fenceDetail.put("longitude", longitude);
        fenceDetail.put("radius", radius);
        params.put("fenceName", fenceName);
        params.put("fenceState", fenceState);
        params.put("triggerSet", triggerSet);
        params.put("fenceId", fenceId);
        return HttpTask.create(METHOD_ELECTRIC_AREA_UPDATE, params, BaseModel.class, callBack)
                       .post();
    }

    @Override
    public HttpTask deleteElectricArea(long fenceId, HttpTask.CallBack callBack) {
        List<String> ids = new ArrayList<>();
        ids.add(String.valueOf(fenceId));
        return deleteElectricAreas(ids, callBack);
    }

    @Override
    public HttpTask deleteElectricAreas(List<String> fenceIds, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("fenceIds", StringUtil.stringListToString(fenceIds, ","));
        return HttpTask.create(METHOD_ELECTRIC_AREA_DELETE, params, BaseModel.class, callBack)
                       .delete();
    }

    @Override
    public HttpTask getWarningConfig(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_WARNING_CONFIG,
                               params,
                               Warning.ResponseList.class,
                               null,
                               new HttpTask.SimpleFlowCallBack() {
                                   @Override
                                   public void onSuccess(HttpTask httpTask,
                                                         Object entity,
                                                         String modelStr) {
                                       Warning.ResponseList res = (Warning.ResponseList) entity;
                                       if (res.size() > 0) {
                                           for (Warning w : res.getData()) {
                                               w.setVehicleCode(vehicleCode);
                                           }
                                       }
                                   }
                               },
                               callBack,
                               null).get();
    }

    @Override
    public HttpTask updateWarningConfig(String vehicleCode,
                                        List<String> alarmIdList,
                                        int appSwitch,
                                        HttpTask.CallBack callBack) {

        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        params.put("alarmIdList", alarmIdList);
        params.put("appSwitch", appSwitch);
        return HttpTask.create(METHOD_WARNING_CONFIG_UPDATE, params, BaseModel.class, callBack)
                       .post();
    }

    @Override
    public HttpTask getVehicleDetailByVin(String vin, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vin", vin);
        return HttpTask.create(METHOD_VEHICLE_DETAIL_BY_VIN,
                               params,
                               Vehicle.ResponseOne.class,
                               callBack).get();
    }

    @Override
    public HttpTask getElectricAreaDetail(long fenceId, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("fenceId", fenceId);
        return HttpTask.create(METHOD_ELECTRIC_AREA_DETAIL,
                               params,
                               ElectricAreaDetail.Resonse.class,
                               callBack).get();
    }

    @Override
    public HttpTask deleteVehicle(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_DELETE_VEHICLE,
                               params,
                               BaseModel.class,
                               null,
                               null,
                               callBack,
                               new HttpTask.SimpleFlowCallBack() {
                                   @Override
                                   public void onSuccess(HttpTask httpTask,
                                                         Object entity,
                                                         String modelStr) {
                                       ActionManager.getInstance()
                                                    .triggerAction(new DeleteVehicleAction(new Vehicle(
                                                            vehicleCode)));
                                   }
                               }).delete();
    }

    @Override
    public HttpTask editVehicle(String vehicleCode,
                                String vehicleNumber,
                                String vehicleNick,
                                HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        if (!TextUtils.isEmpty(vehicleNumber)) {
            params.put("vehicleNumber", vehicleNumber);
        }
        if (!TextUtils.isEmpty(vehicleNick)) {
            params.put("vehicleNick", vehicleNick);
        }
        return HttpTask.create(METHOD_EDIT_VEHICLE,
                               params,
                               BaseModel.class,
                               null,
                               null,
                               callBack,
                               new HttpTask.SimpleFlowCallBack() {
                                   @Override
                                   public void onSuccess(HttpTask httpTask,
                                                         Object entity,
                                                         String modelStr) {
                                       super.onSuccess(httpTask, entity, modelStr);
                                       ActionManager.getInstance()
                                                    .triggerAction(new EditVehicleAction(new Vehicle(
                                                            vehicleCode)));
                                   }
                               }).post();
    }

    @Override
    public HttpTask getTravelAlarms(String travelCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("travelCode", travelCode);
        return HttpTask.create(METHOD_TRAVEL_ALRAMS, params, Warning.ResponseList.class, callBack)
                       .get();
    }

    @Override
    public HttpTask getAlarmConfig(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_EVENT_TYPE_LIST,
                               params,
                               Warning.ResponseList.class,
                               null,
                               new HttpTask.SimpleFlowCallBack() {
                                   @Override
                                   public void onSuccess(HttpTask httpTask,
                                                         Object entity,
                                                         String modelStr) {
                                       super.onSuccess(httpTask, entity, modelStr);
                                       P.putString(Constant.KEY_EVENT_TYPE_CONFIG, modelStr);
                                   }
                               },
                               callBack,
                               null).get();
    }

    @Override
    public HttpTask markAllWarningRead(HttpTask.CallBack callBack) {
        return HttpTask.create(METHOD_MARK_ALL_WARNING_READ, null, BaseModel.class, callBack).get();
    }

    // 诺马
    @Override
    public HttpTask addVehicleNm(String deviceCode,
                               String devicePassword,
                               HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("deviceCode", deviceCode);
        params.put("devicePassword", devicePassword);
        return HttpTask.create(METHOD_VEHICLE_ADD_V, params, BaseModel.class, callBack).post();
    }

    @Override
    public HttpTask getHomeInfoNm(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_HOME_INFO_V, params, VehicleHomeInfo.Response.class, callBack)
                .get();
    }

    @Override
    public HttpTask getLightDataNm(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_LIGHT_DATA_V, params, FindData.Response.class, callBack)
                .get();
    }

    @Override
    public HttpTask sendLightSwitchNm(String vehicleCode, int lightSwitch, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        params.put("lightSwitch", lightSwitch);
        return HttpTask.create(METHOD_LIGHT_SENDSWITCH_V, params, BaseModel.class, callBack)
                .get();
    }

    @Override
    public HttpTask sendLightDurationNm(String vehicleCode, int lightDuration, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        params.put("lightDuration", lightDuration);
        return HttpTask.create(METHOD_LIGHT_SENDDURATION_V, params, BaseModel.class, callBack)
                .get();
    }

    @Override
    public HttpTask getTirePressureStateNm(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_TIRE_STATE_V, params, TireData.Response.class, callBack)
                .get();
    }

    @Override
    public HttpTask getTirePressureDataNm(String vehicleCode, HttpTask.CallBack callBack) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        return HttpTask.create(METHOD_TIRE_DATA_V, params, TireData.Response.class, callBack)
                .get();
    }


    @Override
    public HttpTask fbindDevice(String vehicleCode, String deviceCode, String devicePassword, HttpTask.CallBack callBack){
        HashMap<String, Object> params = new HashMap<>();
        params.put("vehicleCode", vehicleCode);
        params.put("deviceCode", deviceCode);
        params.put("devicePassword", devicePassword);
        return HttpTask.create(METHOD_OPERATION_BINDDEVICE, params, BaseModel.class, callBack).post();
    }

}
